<?php 
	require ("../connect/connect.php");
	include '../template/template_main.tpl';
	require 'estEquipaCtrl.php';
	
	if(isset($_SESSION["profile"]) && !($_SESSION["profile"] == "2" || $_SESSION["profile"] == 1))
		header("Location: ../index.php");
		
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../css/template.css" />
<link rel="stylesheet" type="text/css" href="../css/corpo_main.css" />
<link rel="stylesheet" type="text/css" href="../css/form.css" />
<script type="text/javascript" src="../js/jquery-1.7.2.js" ></script>
<script type="text/javascript" src="../js/main.js" ></script>

<title>.:MateMatrix:.</title>
</head>
<body>
	<?php makeHeader(); ?>
	<?php echo $estruturaInicio;?>
	<div id="forum_opcoes">
	<h1>- Ultimas Três Equipas Registadas -</h1>
	<?php
		echo '<table id="forum_tabela" border=1>
			<tr id="forum_header">
				<th class="topEquipas_Pos">#</th>
				<th class="topEquipas_Equipa">Equipa</th>
				<th class="topEquipas_Equipa">Data Inscrição</th>
			</tr>';	
	
		$resultSet = todasEquipas($conn);
		
		if ($resultSet->num_rows > 0)
		{
			/**
			 *  $row[0] = `equipa`
			 *  $row[1] = `data_inscricao`
			 */
			$i = 0;
			
			while ($row = $resultSet->fetch_row())
			{
				$class = "";
				if (($i%2) == 1)
					$class = "forum_odd_row";
				
				printf("<tr class=\"$class\">
				<td class=\"topEquipas_Pos\">".($i+1)."</td>
				<td class=\"topEquipas_Equipa\">%s</td>
				<td class=\"topEquipas_Pts\">$row[1]</td>
				</tr>",
					htmlspecialchars(iconv("windows-1252","utf-8",$row[0])));
				$i++;
			}
		}
		else 
			echo '<tr><td colspan="2" id="forum_semMsg">Não existem equipas registadas</td></tr>';
		echo '</table>';
	?>
	
		</div>
	<?php echo $estruturaFim;?>
	<?php echo $footer;?>
</body>
</html>
